package com.itheima.web;

import com.itheima.pojo.Checkitem;
import com.itheima.service.CheckitemService;
import com.itheima.support.PageResult;
import com.itheima.support.QueryPageBean;
import com.itheima.support.Result;
import org.apache.dubbo.config.annotation.DubboReference;

import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/checkitem")
public class CheckitemController {

    @DubboReference
    private CheckitemService checkitemService;

    @PostMapping("/add")
    public boolean add(@RequestBody Checkitem checkitem){
        return checkitemService.save(checkitem);
    }

    @PostMapping("/edit")
    public boolean edit(@RequestBody Checkitem checkitem){
        return checkitemService.updateById(checkitem);
    }

    @PostMapping("/save")
    public Result save(@RequestBody Checkitem checkitem){
        return new Result(checkitemService.saveOrUpdate(checkitem));
    }

    @GetMapping("/findAll")
    public List<Checkitem> findAll(){
        return checkitemService.list();
    }

    @PostMapping("/findByPage")
    public PageResult findByPage(@RequestBody QueryPageBean queryPageBean){
        return checkitemService.findByPage(queryPageBean);
    }

    @GetMapping("/deleteById/{id}")
    public boolean deleteById(@PathVariable("id") Long id){
        return checkitemService.removeById(id);
    }

}
